package bin_tree;

import java.util.List;

public class TreeNode {
    public TreeNode left;
    public TreeNode right;
    public int val;
    private StringBuilder tree = new StringBuilder();

    public TreeNode (int val) {
        this.val = val;
    }

    private void inOrder(TreeNode root) {
        if (root == null) {
            return;
        }
        inOrder(root.left);
        tree.append(root.val + " ");
        inOrder(root.right);
    }

    @Override
    public String toString() {
        // 使用中序遍遍历进行打印
        inOrder(this);
        return tree.toString();
    }
}
